<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/header', TEMPLATE_INCLUDEPATH)) : (include template('public/header', TEMPLATE_INCLUDEPATH));?>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('public/comhead', TEMPLATE_INCLUDEPATH)) : (include template('public/comhead', TEMPLATE_INCLUDEPATH));?>

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcss.css">

<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li class="active"><a href="javascript:void(0);">车辆品牌</a></li>
    <li><a href="<?php  echo $this->createWebUrl('car');?>"><i class="fa fa-refresh"></i>返回二手车列表</a></li>
</ul>
<div class="main ygmain">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default ygdefault">

            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">添加品牌首字母</label>
                    <div class="col-sm-9">
                        <input type="text" name="zimu" class="form-control col-sm-3 " value="<?php  echo $info['zimu'];?>" style="width: 390px;" />
                        <!-- <input type="submit" name="submit" value="提交" class="btn " style="color: white;background-color: #444444;margin-left: 50px;;"/> -->
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">添加品牌名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="name" class="form-control col-sm-3 " value="<?php  echo $info['name'];?>" style="width: 390px;" />
                    </div>
                </div>
                        <input type="submit" name="submit" value="提交" class="btn " style="color: white;background-color: #444444;margin-left: 50px;;"/>

            </div>


            <input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
            <input type="hidden" name="id" value="<?php  echo $info['id'];?>" />
        </div>
    </form>
    <div class="panel panel-default ygdefault">
        <div class="panel-heading wyheader">

            品牌列表

        </div>
    </div>
    <div class="panel-body" style="padding: 0px 15px;">
        <div class="row" id="accordion">

            <table class="yg5_tabel col-md-12">

                <tr class="yg5_tr1" style="border-bottom: 1px solid #efefef;font-weight: bold;text-align: center;">
                    <td  style="text-align: center;">编号</td>
                    <td  style="text-align: center;">首字母</td>
                    <td  style="text-align: center;">品牌名称</td>
                    <td>操作</td>
                </tr>

                <?php  if(is_array($info)) { foreach($info as $key => $item) { ?>
                <tbody>
                <tr class="yg5_tr2" style="border-bottom: 1px solid #efefef;font-weight: bold;text-align: center;">

                    <td><?php  echo $item['id'];?></td>
                    <td><?php  echo $item['zimu'];?></td>
                    <td><?php  echo $item['name'];?></td>
                    <td>
                        <a class="storespan btn btn-xs" onclick="del(<?php  echo $item['id'];?>,<?php  echo $item['num'];?>)">
                            <span class="fa fa-trash-o"></span>
                            <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                        </a>
                    </td>
                </tr>
                </tbody>
                <?php  } } ?>
                <?php  if(empty($item)) { ?>
                <tr class="yg5_tr2">
                    <td colspan="8">
                       暂无分类
                    </td>
                </tr>
                <?php  } ?>
            </table>
        </div>
    </div>

</div>
<script type="text/javascript">
    $(function(){
        $("#frame-8").show();
        $("#yframe-8").addClass("wyactive");
    })
    function del(id,num) {
        if(num>0){
            alert('当前品牌下有'+num+'辆车，无法删除，请先修改车辆所属品牌')
        }else{
            var ret = confirm("您确定删除吗？")
            if (ret==true){
                $.ajax({
                    type:"POST",
                    url:"<?php  echo $this->createWebUrl('carbrand',array('op'=>delete))?>",
                    dataType:"JSON",
                    data:{id:id},
                    success:function(res){
                        console.log(res);
                        location.reload();

                    }
                })
            }
        }

    }
</script>